package com.zcy.auth.service.impl;

import com.zcy.auth.domain.Permission;
import com.zcy.auth.mapper.PermissionMapper;
import com.zcy.auth.service.IPermissionService;
import com.zcy.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 权限 服务实现类
 * </p>
 *
 * @author lucker
 * @since 2023-12-02
 */
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class PermissionServiceImpl extends BaseServiceImpl<Permission> implements IPermissionService {


    @Autowired
    private PermissionMapper permissionMapper;

    @Transactional
    @Override
    public void deleteAll() {
        permissionMapper.deleteAll();
    }

    @Override
    public void addBatch(List<Permission> permissionList) {
        permissionMapper.addBatch(permissionList);
    }

    @Override
    public List<Permission> getPermissionTree() {
        return permissionMapper.getPermissionTree();
    }

    @Override
    public List<Permission> getRolePermissionTree(Serializable id) {
        return permissionMapper.getPermissionTreeByRoleId(id);
    }

    @Override
    public List<Long> getPermissionIdsByRoleId(Serializable id) {
        return permissionMapper.getPermissionIdsByRoleId(id);
    }
}
